/**
 * 
 * @author bigk
 * @version 0.8.5
 * 
 * 
 * Copyright (C) 2012  bigktheone@gmail.com

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */
package bigk.pluzzdl.activity;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import bigk.pluzzdl.Globals;
import bigk.pluzzdl.Logger;
import bigk.pluzzdl.model.Channel;

public class ProgramActivity extends ListActivity {
	
	private Logger m_logger;
	
	private String m_selectedChannel;

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		m_logger = Logger.getLogger(ChannelActivity.class.getName());
		Globals.setupLogger(Globals.APP_LEVEL, m_logger);

		
		Bundle _extras = getIntent().getExtras();
		m_selectedChannel = _extras.getString("selectedChannel");
		Channel _channel = Globals.getPluzzList().getChannel(m_selectedChannel);
		
		String[] _values = _channel.getProgramsAsString();
		
		ArrayAdapter<String> _adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, _values);
		setListAdapter(_adapter);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		
		String _value = this.getListAdapter().getItem(position).toString();
		Intent _intent = new Intent(this, FileActivity.class);
		_intent.putExtra("selectedProgram", _value);
		_intent.putExtra("selectedChannel", m_selectedChannel);
		startActivity(_intent);
	}
	
	
	
}
